package com.power.service.impl;

import com.power.dao.TowerDao;
import com.power.dao.impl.TowerDaoImpl;
import com.power.ov.ResultData;
import com.power.ov.ResultDataTable;
import com.power.pojo.Tower;
import com.power.service.TowerService;

import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * User: 李辽
 * Date: 2020/10/03 17:03
 * Description:
 * Version: V1.0
 */
public class TowerServiceImpl implements TowerService {
    TowerDao TowerDao = new TowerDaoImpl();

    @Override
    public ResultDataTable queryListPower(int page,int limit) throws SQLException {
        System.out.println("进入service"+page);
        return TowerDao.queryListPower(page,limit);
    }

    @Override
    public int DeleteTowerByName(int towper_id) throws SQLException {
        System.out.println("进入删除后台service");
        return TowerDao.DeleteTowerByName(towper_id);
    }

    @Override
    public int ChangeTower(Tower tower1) throws SQLException {
        System.out.println("到达测试后代servce");
        return TowerDao.ChangeTower(tower1);
    }



    @Override
    public int Addtopwer(Tower tower1) throws SQLException {
        return TowerDao.Addtopwer(tower1);
    }



    @Override
    public ResultDataTable SearchTower(int page, int limit, String line_number, int tower_state) throws SQLException {

        int line_id= queryLineIdByIneNumber(line_number);
        return TowerDao.SearchTower(page,limit,line_id,tower_state);
    }
    private int queryLineIdByIneNumber(String line_number) throws SQLException {
        int result = TowerDao.queryLineIdByIneNumber(line_number);
        return result;
    }

    @Override
    public int ModifiesTowerStatus(int towper_id, String  state_name) throws SQLException {
        int newState = 0;
        if (state_name.equals("启用")){
            newState = 2;
        }else {
            newState = 1;
        }
        return TowerDao.ModifiesTowerStatus(towper_id,newState);
    }

    @Override
    public ResultData DefectSelect(String line_id) throws SQLException {
        return TowerDao.DefectSelect(line_id);
    }


}
